#include "Navigatebar.h"
#include <QPushButton>
#include <QHBoxLayout>
#include "../../controller/SignalBus.h"

Navigatebar::Navigatebar(QWidget *parent)
    : QWidget{parent}
{
    setupUi();
}

void Navigatebar::setupUi()
{
    initWidgets();
    if(!buttonList.empty())
    {
        for(int index=0;index<buttonList.count();index++)
        {
            connect(buttonList[index],&QPushButton::clicked,[=](){emit SignalBus::instance()->GotoPage(index);});
        }
    }
}

void Navigatebar::initWidgets()
{
    const auto btnHomePage = new QPushButton();
    const auto btnSettingPage = new QPushButton();

    const auto layout = new QHBoxLayout();

    btnHomePage->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
    btnSettingPage->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
    layout->addWidget(btnHomePage);
    layout->addWidget(btnSettingPage);

    setLayout(layout);
    buttonList.append(btnHomePage);
    buttonList.append(btnSettingPage);
}
